{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pandas import Series, DataFrame\n",
    "\n",
    "df_2019_jul = pd.read_csv('../data/nyc_taxi_2019-07.csv',\n",
    "                usecols=['passenger_count', \n",
    "                        'total_amount', 'payment_type'])\n",
    "df_2019_jul['year'] = 2019\n",
    "\n",
    "df_2020_jul = pd.read_csv('../data/nyc_taxi_2020-07.csv',\n",
    "                usecols=['passenger_count', \n",
    "                        'total_amount', 'payment_type'])\n",
    "df_2020_jul['year'] = 2020\n",
    "\n",
    "df = pd.concat([df_2019_jul, df_2020_jul])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5510007"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# How many rides were taken in 2019 vs. 2020?\n",
    "(\n",
    "    df.loc[df['year'] == 2019, 'total_amount'].count() -\n",
    "    df.loc[df['year'] == 2020, 'total_amount'].count()\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "108848979.24000001"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# How much money was collected in 2019 vs. 2020?\n",
    "(\n",
    "    df.loc[df['year'] == 2019, 'total_amount'].sum() -\n",
    "    df.loc[df['year'] == 2020, 'total_amount'].sum()\n",
    ")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.2833900000955953"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Did the proportion of trips with more than passenger change dramatically?\n",
    "df.loc[(df['year'] == 2019) & \n",
    "       (df['passenger_count'] > 1), 'passenger_count'].count() / df.loc[df['year'] == 2019, 'payment_type'].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.2061513222563435"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[(df['year'] == 2020) & \n",
    "       (df['passenger_count'] > 1), 'passenger_count'].count() / df.loc[df['year'] == 2020, 'payment_type'].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.2870595845428793"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Did people use cash less in 2019 or 2020?\n",
    "df.loc[(df['year'] == 2019) & \n",
    "       (df['payment_type'] == 2), 'payment_type'].count() / df.loc[df['year'] == 2019, 'payment_type'].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.320558865998251"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[(df['year'] == 2020) & \n",
    "       (df['payment_type'] == 2), 'payment_type'].count() / df.loc[df['year'] == 2020, 'payment_type'].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
